/******************************************************************************/
/*                                                                            */
/*  Copyright (c) 2009: ngi-central.org                                       */
/*  All rights reserved.                                                      */
/*                                                                            */
/******************************************************************************/


#include <boost/test/unit_test.hpp>

#include "..\..\include\sgl\hu_moments.h"

BOOST_AUTO_TEST_SUITE( hu_moments )


BOOST_AUTO_TEST_CASE( hu_moments__default_constructor )
{
	sgl::hu_moments<> a;

	BOOST_CHECK( a.phi1() == 0 );
	BOOST_CHECK( a.phi2() == 0 );
	BOOST_CHECK( a.phi3() == 0 );
	BOOST_CHECK( a.phi4() == 0 );
	BOOST_CHECK( a.phi5() == 0 );
	BOOST_CHECK( a.phi6() == 0 );
	BOOST_CHECK( a.phi7() == 0 );

	sgl::hu_moments<> b(1, 2, 3, 4, 5, 6, 7);

	BOOST_CHECK( b.phi1() == 1 );
	BOOST_CHECK( b.phi2() == 2 );
	BOOST_CHECK( b.phi3() == 3 );
	BOOST_CHECK( b.phi4() == 4 );
	BOOST_CHECK( b.phi5() == 5 );
	BOOST_CHECK( b.phi6() == 6 );
	BOOST_CHECK( b.phi7() == 7 );
}

BOOST_AUTO_TEST_CASE( hu_moments__copy_constructor )
{
	sgl::hu_moments<> a(
		sgl::hu_moments<>(1, 2, 3, 4, 5, 6, 7));

	BOOST_CHECK( a.phi1() == 1 );
	BOOST_CHECK( a.phi2() == 2 );
	BOOST_CHECK( a.phi3() == 3 );
	BOOST_CHECK( a.phi4() == 4 );
	BOOST_CHECK( a.phi5() == 5 );
	BOOST_CHECK( a.phi6() == 6 );
	BOOST_CHECK( a.phi7() == 7 );
}

BOOST_AUTO_TEST_CASE( normalized_moments__conversion_copy_constructor )
{
	sgl::hu_moments<> a(
		sgl::scale_invariant_moments<>(1, 2, 3, 4, 5, 6, 7));

	BOOST_CHECK( a.phi1() == 4 );
	BOOST_CHECK( a.phi2() == 20 );
	BOOST_CHECK( a.phi3() == 260 );
	BOOST_CHECK( a.phi4() == 244 );
	BOOST_CHECK( a.phi5() == 61456 );
	BOOST_CHECK( a.phi6() == 1048 );
	BOOST_CHECK( a.phi7() == -352 );
}

BOOST_AUTO_TEST_CASE( hu_moments__copy_assignment )
{
	sgl::hu_moments<> a;
	a = sgl::hu_moments<>(1, 2, 3, 4, 5, 6, 7);

	BOOST_CHECK( a.phi1() == 1 );
	BOOST_CHECK( a.phi2() == 2 );
	BOOST_CHECK( a.phi3() == 3 );
	BOOST_CHECK( a.phi4() == 4 );
	BOOST_CHECK( a.phi5() == 5 );
	BOOST_CHECK( a.phi6() == 6 );
	BOOST_CHECK( a.phi7() == 7 );
}

BOOST_AUTO_TEST_CASE( hu_moments__swap )
{
	sgl::hu_moments<> a(
		sgl::hu_moments<>(1, 2, 3, 4, 5, 6, 7));
	sgl::hu_moments<> b;

	a.swap(b);

	BOOST_CHECK( a.phi1() == 0 );
	BOOST_CHECK( a.phi2() == 0 );
	BOOST_CHECK( a.phi3() == 0 );
	BOOST_CHECK( a.phi4() == 0 );
	BOOST_CHECK( a.phi5() == 0 );
	BOOST_CHECK( a.phi6() == 0 );
	BOOST_CHECK( a.phi7() == 0 );
	BOOST_CHECK( b.phi1() == 1 );
	BOOST_CHECK( b.phi2() == 2 );
	BOOST_CHECK( b.phi3() == 3 );
	BOOST_CHECK( b.phi4() == 4 );
	BOOST_CHECK( b.phi5() == 5 );
	BOOST_CHECK( b.phi6() == 6 );
	BOOST_CHECK( b.phi7() == 7 );

	b.swap(a);

	BOOST_CHECK( a.phi1() == 1 );
	BOOST_CHECK( a.phi2() == 2 );
	BOOST_CHECK( a.phi3() == 3 );
	BOOST_CHECK( a.phi4() == 4 );
	BOOST_CHECK( a.phi5() == 5 );
	BOOST_CHECK( a.phi6() == 6 );
	BOOST_CHECK( a.phi7() == 7 );
	BOOST_CHECK( b.phi1() == 0 );
	BOOST_CHECK( b.phi2() == 0 );
	BOOST_CHECK( b.phi3() == 0 );
	BOOST_CHECK( b.phi4() == 0 );
	BOOST_CHECK( b.phi5() == 0 );
	BOOST_CHECK( b.phi6() == 0 );
	BOOST_CHECK( b.phi7() == 0 );
}

BOOST_AUTO_TEST_CASE( hu_moments__phi1 )
{
	sgl::hu_moments<> a;

	BOOST_CHECK( a.phi1() == 0 );

	a.phi1() = 1;

	BOOST_CHECK( a.phi1() == 1 );
}

BOOST_AUTO_TEST_CASE( hu_moments__phi2 )
{
	sgl::hu_moments<> a;

	BOOST_CHECK( a.phi2() == 0 );

	a.phi2() = 1;

	BOOST_CHECK( a.phi2() == 1 );
}

BOOST_AUTO_TEST_CASE( hu_moments__phi3 )
{
	sgl::hu_moments<> a;

	BOOST_CHECK( a.phi3() == 0 );

	a.phi3() = 1;

	BOOST_CHECK( a.phi3() == 1 );
}

BOOST_AUTO_TEST_CASE( hu_moments__phi4 )
{
	sgl::hu_moments<> a;

	BOOST_CHECK( a.phi4() == 0 );

	a.phi4() = 1;

	BOOST_CHECK( a.phi4() == 1 );
}

BOOST_AUTO_TEST_CASE( hu_moments__phi5 )
{
	sgl::hu_moments<> a;

	BOOST_CHECK( a.phi5() == 0 );

	a.phi5() = 1;

	BOOST_CHECK( a.phi5() == 1 );
}

BOOST_AUTO_TEST_CASE( hu_moments__phi6 )
{
	sgl::hu_moments<> a;

	BOOST_CHECK( a.phi6() == 0 );

	a.phi6() = 1;

	BOOST_CHECK( a.phi6() == 1 );
}

BOOST_AUTO_TEST_CASE( hu_moments__phi7 )
{
	sgl::hu_moments<> a;

	BOOST_CHECK( a.phi7() == 0 );

	a.phi7() = 1;

	BOOST_CHECK( a.phi7() == 1 );
}

BOOST_AUTO_TEST_CASE( hu_moments__operator_equality )
{
	sgl::hu_moments<> a;
	sgl::hu_moments<> b;

	BOOST_CHECK( a == b );

	sgl::hu_moments<> c(1, 2, 3, 4, 5, 6, 7);
	sgl::hu_moments<> d(1, 2, 3, 4, 5, 6, 7);

	BOOST_CHECK( c == d );
}

BOOST_AUTO_TEST_CASE( hu_moments__operator_inequality )
{
	sgl::hu_moments<> a;
	sgl::hu_moments<> b(1, 2, 3, 4, 5, 6, 7);

	BOOST_CHECK( a != b );
}

BOOST_AUTO_TEST_SUITE_END()

